package itdfq.dfq.Behavior_Patters.Iterator;

/**
 * @Author GocChin
 * @Date 2021/5/15 13:53
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Descript:
 */
public class Client {
    public static void main(String[] args) {
        System.out.println("18031210111  段方钦");
        Music music;
        music= (Music) XMLUtil.getBean();
        display(music);
        System.out.println("----------------");
        reverseDisplay(music);

    }
    public static void display(Music music){
        MusicIterator iterator = music.createIterator();
        System.out.println("音乐列表：");
        while (!iterator.isLast()){
            System.out.println(iterator.currentmusic().toString());
            iterator.next();
        }
    }
    public static void reverseDisplay(Music music){
        MusicIterator iterator = music.createIterator();
        iterator.setmusic(3);
        System.out.println("逆向遍历音乐列表：");
        while (!iterator.isFirst()){
            iterator.previous();
            System.out.println(iterator.currentmusic().toString());

        }
    }
}
